package com.zhu.load;

import com.sun.crypto.provider.DESKeyFactory;
import lombok.extern.slf4j.Slf4j;
import sun.misc.Launcher;

import java.net.URL;

/**
 * @ClassName TestJdkClassLoad
 * @Description TODO
 * @Author zhuxiongbin
 * @Date 2021-11-03 9:46
 * @Version 1.0.0
 */
@Slf4j(topic = "zhu")
public class TestJdkClassLoad {

    public static void main(String[] args) {
        System.out.println(String.class.getClassLoader());
        System.out.println(DESKeyFactory.class.getClassLoader());
        System.out.println(TestJdkClassLoad.class.getClassLoader());

        System.out.println("===================");

        ClassLoader app = ClassLoader.getSystemClassLoader();
        ClassLoader ext = app.getParent();
        ClassLoader bootstrapLoader = ext.getParent();

        System.out.println("bootstrapLoader : "+bootstrapLoader);
        System.out.println("extClassLoader : "+ext);
        System.out.println("appClassLoader : "+app);

        System.out.println("===================");

        System.out.println("bootstrapLoader加载以下文件：");
        URL[] urLs = Launcher.getBootstrapClassPath().getURLs();
        for (int i = 0; i < urLs.length; i++) {
            System.out.println(urLs[i]);
        }

        System.out.println("extClassLoader加载以下文件：");
        System.out.println(System.getProperty("java.ext.dirs"));

        System.out.println("appClassLoader加载以下文件：");
        System.out.println(System.getProperty("java.class.path"));
    }
}
